import request from '@/utils/request';

// 节点及连线数据
export function getNetTopology(id: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/netTopology/' + id,
		method: 'get',
	});
}

// 获取节点信息
export function getNodeInfo(id: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/netTopology/getComponent/' + id,
		method: 'get',
	});
}

// 添加连线
export function addLink(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/netTopology/addLink',
		method: 'post',
		data: data,
	});
}

// 删除连线
export function deleteLink(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/netTopology/removeLink',
		method: 'post',
		data: data,
	});
}

// 修改组件信息
export function updateComponentInfo(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/netTopology/updateNode',
		method: 'post',
		data: data,
	});
}

// 移动组件
export function setComponentLocation(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/netTopology/setLocation',
		method: 'post',
		data: data,
	});
}

// 删除节点
export function deleteComponentInfo(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/netTopology/removeNode',
		method: 'post',
		data: data,
	});
}

// 新增节点
export function addComponentInfo(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/netTopology/addNode',
		method: 'post',
		data: data,
	});
}

// 所在位置下拉列表
export function netType(): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/system/dict/data/type/net_type',
		method: 'get',
	});
}

// 连接方式下拉列表
export function connectType(): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/system/dict/data/type/connect_type',
		method: 'get',
	});
}

// 基础设施下拉列表
export function getDeviceInfo(): ApiPromise<ApiResponse> {
	return request({
		url: '/management/device/getDeviceInfo',
		method: 'get',
	});
}

// 新增ip
export function addIpConfig(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/netTopologyComponentIp/save',
		method: 'post',
		data: data,
	});
}

// 修改ip
export function updateIpConfig(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/netTopologyComponentIp',
		method: 'put',
		data: data,
	});
}

// 删除ip
export function deleteIpConfig(id: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/netTopologyComponentIp/delete/' + id,
		method: 'delete',
		// data: data,
	});
}

// 查询ip
export function getAllIp(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/netTopologyComponentIp',
		method: 'post',
		data: data,
	});
}
